package com.zqj.project.factory;

import com.zqj.project.common.database.mybatis.conditions.Wraps;
import com.zqj.project.common.database.mybatis.conditions.query.LbqWrapper;
import com.zqj.project.entity.CartPO;
import com.zqj.project.model.Cart;

import java.util.Objects;

/**
 * @Description: CartFactory
 * @Author: 22001010704 Zhang Qijian
 * @CreateTime: 2024/12/8 18:53
 * @Version: 1.0
 */
public class CartFactory {

    private CartFactory() {
        throw new IllegalStateException("Utility Class");
    }

    public static LbqWrapper<CartPO> lbqWrapper(Cart cart) {
        return Wraps.<CartPO>lbQ().eq(Objects.nonNull(cart.getUserId()), CartPO::getUserId, cart.getUserId())
                .eq(Objects.nonNull(cart.getProductId()), CartPO::getProductId, cart.getProductId())
                .orderByDesc(CartPO::getCreateTime);
    }

}